package com.hirisun.calendar.time;

import java.util.HashMap;

public class ConversionRatioManager {
	private HashMap<Unit,ConversionRatio> conversionRatios = new HashMap<Unit, ConversionRatio>();
	
	
	
	public void addConversionRatio(ConversionRatio conversionRatio){
		conversionRatios.put(conversionRatio.getFrom(), conversionRatio);
	}
	
	public int getConversionRatio(Unit unit){
		return conversionRatios.get(unit).getRatio();
	}
	
	public int getUnit(char c){
		
		int result = 0;
		switch (c) {
		case 'y':
			result = getConversionRatio(Unit.YEAR);
			break;
		case 'm':
			result = getConversionRatio(Unit.MONTH);
			break;
		case 'w':
			result = getConversionRatio(Unit.WEEK);
			break;
		case 'd':
			result = getConversionRatio(Unit.DAY);
			break;
		case 'h':
			result = getConversionRatio(Unit.HOUR);
			break;
		case 'f':
			result = getConversionRatio(Unit.MINUTE);
			break;
		}
		return result;
		
	}
}
